package com.zyx.xml.dom;

import cn.hutool.core.io.resource.ClassPathResource;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

/**
 * Description:
 * <br/> 10.2.4 使用DTD验证XML文档
 *
 * @author Yaxi.Zhang
 * @since 2022/9/25 08:03
 */
public class DTDValidate {
    public static void main(String[] args) throws Exception {
        //DOM解析器工厂
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        //设置使用DTD验证XML文档
        factory.setValidating(true);
        //获取DOM解析器
        DocumentBuilder builder = factory.newDocumentBuilder();
        //开始解析XML文档
        builder.parse(new ClassPathResource("ch10_02/book.xml").getFile());
    }

}
